home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / debugger / ddd-1.000 / ddd-1 / ddd-1.4b / ddd / BoxGraphN.C < prev    next >
Encoding:
C/C++ Source or Header  |  1996-01-04  |  3.6 KB  |  138 lines

  1. // $Id: BoxGraphN.C,v 1.6 1996/01/04 16:28:23 zeller Exp $
  2. // BoxGraphNode class: RegionGraphNode with box
  3.  
  4. // Copyright (C) 1995 Technische Universitaet Braunschweig, Germany.
  5. // Written by Andreas Zeller (zeller@ips.cs.tu-bs.de).
  6. // 
  7. // This file is part of the DDD Library.
  8. // 
  9. // The DDD Library is free software; you can redistribute it and/or
  10. // modify it under the terms of the GNU Library General Public
  11. // License as published by the Free Software Foundation; either
  12. // version 2 of the License, or (at your option) any later version.
  13. // 
  14. // The DDD Library is distributed in the hope that it will be useful,
  15. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  17. // See the GNU Library General Public License for more details.
  18. // 
  19. // You should have received a copy of the GNU Library General Public
  20. // License along with the DDD Library -- see the file COPYING.LIB.
  21. // If not, write to the Free Software Foundation, Inc.,
  22. // 675 Mass Ave, Cambridge, MA 02139, USA.
  23. // 
  24. // DDD is the data display debugger.
  25. // For details, see the DDD World-Wide-Web page, 
  26. // `http://www.cs.tu-bs.de/softech/ddd/',
  27. // or send a mail to the DDD developers at `ddd@ips.cs.tu-bs.de'.
  28.  
  29. char BoxGraphNode_rcsid[] = 
  30.     "$Id: BoxGraphN.C,v 1.6 1996/01/04 16:28:23 zeller Exp $";
  31.  
  32. #ifdef __GNUG__
  33. #pragma implementation
  34. #endif
  35.  
  36. #include "BoxGraphN.h"
  37. #include "printBox.h"
  38. #include "CompositeB.h"
  39.  
  40.  
  41. DEFINE_TYPE_INFO_1(BoxGraphNode, RegionGraphNode)
  42.  
  43. // Draw a BoxGraphNode
  44. void BoxGraphNode::forceDraw(Widget w, 
  45.                  const BoxRegion&, 
  46.                  const GraphGC& gc) const
  47. {
  48.     // We do not check for exposures here --
  49.     // boxes are usually small and partial display
  50.     // doesn't work well with scrolling
  51.  
  52.     box()->draw(w, region(gc), region(gc), gc.nodeGC, false);
  53. }
  54.  
  55.  
  56. // mark the following objects as one XFIG compound object
  57. static void startCompound(ostream& os, BoxRegion region)
  58. {
  59.     BoxPoint origin = region.origin();
  60.     BoxPoint width = region.space();
  61.  
  62.     os << CMPHEAD;
  63.     os << origin[X] + width[X] + 1 << " " << origin[Y] - 1 << " ";
  64.     os << origin[X] - 1 << " " << origin[Y] + width[Y] + 1 << "\n";
  65. }
  66.  
  67. static void endCompound(ostream& os)
  68. {
  69.     os << CMPTAIL;
  70. }
  71.  
  72.  
  73. // Print a BoxGraphNode
  74. void BoxGraphNode::_print(ostream& os, const GraphGC& gc) const
  75. {
  76.     if (gc.printGC->isFig())
  77.     startCompound(os, region(gc));
  78.  
  79.     RegionGraphNode::_print(os, gc);
  80.     box()->_print(os, (BoxRegion&)region(gc), *gc.printGC);
  81.  
  82.     if (gc.printGC->isFig())
  83.     endCompound(os);
  84. }
  85.  
  86. // MARK is a MarkBox in SRC.  Find equivalent box in DUP.
  87. MarkBox *BoxGraphNode::find_mark(Box *dup, Box *src, Box *mark)
  88. {
  89.     if (mark == 0)
  90.     return 0;
  91.  
  92.     if (src == mark)
  93.     {
  94.     MarkBox *dup_mb = ptr_cast(MarkBox, dup);
  95.     assert(dup_mb != 0);
  96.     return dup_mb;
  97.     }
  98.  
  99.     // Try Composite children
  100.     CompositeBox *src_cb = ptr_cast(CompositeBox, src);
  101.     if (src_cb != 0)
  102.     {
  103.     CompositeBox *dup_cb = ptr_cast(CompositeBox, dup);
  104.     assert(dup_cb != 0);
  105.     assert(src_cb->nchildren() == dup_cb->nchildren());
  106.  
  107.     for (int i = 0; i < src_cb->nchildren(); i++)
  108.     {
  109.         MarkBox *mb = 
  110.         find_mark((*dup_cb)[i], (*src_cb)[i], mark);
  111.         if (mb)
  112.         return mb;
  113.     }
  114.  
  115.     return 0;
  116.     }
  117.  
  118.     // Try HatBox child
  119.     HatBox *src_hb = ptr_cast(HatBox, src);
  120.     if (src_hb != 0)
  121.     {
  122.     HatBox *dup_hb = ptr_cast(HatBox, dup);
  123.     assert(dup_hb != 0);
  124.  
  125.     return find_mark(dup_hb->box(), src_hb->box(), mark);
  126.     }
  127.  
  128.     return 0;
  129. }
  130.     
  131.  
  132. // Copy Constructor
  133. BoxGraphNode::BoxGraphNode(const BoxGraphNode& node):
  134.     RegionGraphNode(node),
  135.     _box(node._box->dup()),
  136.     _highlight(find_mark(_box, node._box, node._highlight))
  137. {}
  138.